package main

import (
	"gitee.com/chejiangyi/bsfgo/demo/web/controller/admin"
	"gitee.com/chejiangyi/bsfgo/demo/web/controller/api"
	"gitee.com/chejiangyi/bsfgo/gin2/route2"
	"github.com/gin-gonic/gin"
)

func InitRoutes(r *gin.Engine) *gin.Engine {
	adminRoute := r.Group("/admin")
	{
		homeHttpMethods := []string{"GET", "POST"}
		/*home*/
		home := &admin.HomeController{}
		route2.RouteUtil.AutoRegisterRoutes(homeHttpMethods, adminRoute, home)
		//adminRoute.GET("/home/error", home.Error)
		//adminRoute.Match([]string{"GET", "POST"}, "/home/index", home.Index)
		//adminRoute.POST("/home/login", home.Login)
		//adminRoute.POST("/home/loginOut", home.LoginOut)
		/*user*/
		user := &admin.UserController{}
		route2.RouteUtil.AutoRegisterRoutes(homeHttpMethods, adminRoute, user)
		//adminRoute.Match([]string{"GET", "POST"}, "/user/index", user.Index)
		//adminRoute.Match([]string{"GET", "POST"}, "/user/edit", user.Edit)
		//adminRoute.POST("/user/save", user.Save)
	}
	apiRoute := r.Group("/api")
	{
		apiHttpMethods := []string{"POST"}
		/*test*/
		test := &api.TestController{}
		//自动注册
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, test)
		//手工注册
		//apiRoute.POST("/test/getUserSearch", test.GetUserSearch)
		//apiRoute.POST("/test/getError", test.GetError)
		/*redis2*/
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, &api.RedisController{})
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, &api.GormController{})
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, &api.KafkaController{})
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, &api.HttpController{})
		route2.RouteUtil.AutoRegisterRoutes(apiHttpMethods, apiRoute, &api.TokenController{})
	}
	return r
}
